<?php
	$sql = new db();
	
	$req = "SELECT ca.* FROM type_camion AS tyc, camion AS ca  WHERE";
	if (isset($_POST['classenv']))
		$req .= " ClassEnv ='".$_POST['classenv']."' AND ";
	if (isset($_POST['capvolume']))
		$req .= " Capacite_Volume ='".$_POST['capvolume']."' AND ";
	if (isset($_POST['cappalette']))
		$req .= " Capacite_Nb_Palette ='".$_POST['cappalette']."' AND ";
	if (isset($_POST['cappoids']))
		$req .= " Capacite_Poids ='".$_POST['cappoids']."' AND ";
	if (isset ($_POST['date']))
		$req .= " ca.Matricule NOT IN ( SELECT Matricule FROM tournee WHERE '".$_POST['date']." ".$_POST['heure']."' BETWEEN date_debut AND date_fin ) AND ";
	$req .= " ca.Id_caractere = tyc.Id_caractere AND GLN_Transporteur ='".$_SESSION['login']."' GROUP BY ca.Matricule";
	$sql->query($req);
	if ($sql->num_rows() > 0)
	{
		$array = array();
		while ($res = $sql->fetch_array())
			$array[] = $res;
	}
?>